var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "react", "services/weixin", "maishu-ui-toolkit", "controls/spiner-component"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    const React = require("react");
    const weixin_1 = require("services/weixin");
    const ui = require("maishu-ui-toolkit");
    const spiner_component_1 = require("controls/spiner-component");
    const label_max_width = 120;
    const input_max_width = 300;
    class SettingPage extends spiner_component_1.SpinerComponent {
        constructor(props) {
            super(props);
            this.state = { setting: this.props.setting };
            this.weixin = this.props.createService(weixin_1.WeiXinService);
        }
        loadData() {
            return __awaiter(this, void 0, void 0, function* () {
                let setting = yield this.weixin.getSetting();
                return { setting };
            });
        }
        save() {
            return this.weixin.saveSetting(this.state.setting);
        }
        render() {
            let setting = this.state.setting;
            return React.createElement(React.Fragment, null,
                React.createElement("ul", { key: 10, className: "nav nav-tabs" },
                    React.createElement("li", { className: "pull-right" },
                        React.createElement("button", { className: "btn btn-primary btn-sm", ref: (e) => {
                                if (!e)
                                    return;
                                ui.buttonOnClick(e, () => this.save(), { toast: "保存成功" });
                            } },
                            React.createElement("i", { className: "icon-save" }),
                            React.createElement("span", null, "\u4FDD\u5B58")))),
                React.createElement("div", { key: 20, className: "well" },
                    React.createElement("div", { className: "row form-group" },
                        React.createElement("div", { className: "col-md-12" },
                            React.createElement("h5", null, "\u516C\u4F17\u53F7\u8BBE\u7F6E"))),
                    React.createElement("div", { className: "row form-group" },
                        React.createElement("label", { className: "col-md-4", style: { width: label_max_width } }, "AppId"),
                        React.createElement("div", { className: "col-md-8", style: { maxWidth: input_max_width } },
                            React.createElement("input", { name: "AppId", className: "form-control", value: setting.AppId || '', onChange: (e) => {
                                    setting.AppId = e.target.value;
                                    this.setState(this.state);
                                } }))),
                    React.createElement("div", { className: "row form-group" },
                        React.createElement("label", { className: "col-md-4", style: { width: label_max_width } }, "AppSecret"),
                        React.createElement("div", { className: "col-md-8", style: { maxWidth: input_max_width } },
                            React.createElement("input", { name: "AppSecret", className: "form-control", value: setting.AppSecret || '', onChange: (e) => {
                                    setting.AppSecret = e.target.value;
                                    this.setState(this.state);
                                } }))),
                    React.createElement("div", { className: "row form-group" },
                        React.createElement("div", { className: "col-md-12" },
                            React.createElement("h5", null, "\u5FAE\u652F\u4ED8\u8BBE\u7F6E"))),
                    React.createElement("div", { className: "row form-group" },
                        React.createElement("label", { className: "col-md-4", style: { width: label_max_width } }, "PartnerId"),
                        React.createElement("div", { className: "col-md-8", style: { maxWidth: input_max_width } },
                            React.createElement("input", { name: "PartnerId", className: "form-control", value: setting.PartnerId || '', onChange: (e) => {
                                    setting.PartnerId = e.target.value;
                                    this.setState(this.state);
                                } }))),
                    React.createElement("div", { className: "row form-group" },
                        React.createElement("label", { className: "col-md-4", style: { width: label_max_width } }, "PartnerKey"),
                        React.createElement("div", { className: "col-md-8", style: { maxWidth: input_max_width } },
                            React.createElement("input", { name: "PartnerKey", className: "form-control", value: setting.PartnerKey || '', onChange: (e) => {
                                    setting.PartnerKey = e.target.value;
                                    this.setState(this.state);
                                } })))));
        }
    }
    exports.default = SettingPage;
});
// let setting = await weixin.getSetting();
// ReactDOM.render(<SettingPage setting={setting} />, page.element)
